<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl() ?>/public/css/input.css"/>
<link href="<?php echo $this->baseUrl() ?>/public/css/default.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo $this->baseUrl() ?>/public/css/nivo-slider.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo $this->baseUrl() ?>/public/css/detail.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="<?php echo $this->baseUrl() ?>/public/js/prettyphoto/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />

<div id="detail-content">
    <?php if (isset($this->generalinfo)): ?>
        <div class="c1">
            <h1 style="width:240px;">GENERAL INFORMATION</h1>

            <div class="cleft">
                <label for="shipname">Ship name</label>

                <div class="fill" id="shipname"><?php echo $this->generalinfo["ship_name"] ?></div>
                <label for="voyageno">Customer name</label>

                <div class="fill" id="voyageno"><?php echo $this->generalinfo["fullname"] ?></div>
                <label for="portofcall">Port</label>

                <div class="fill" id="portofcall"><?php echo $this->generalinfo["port_name"] ?></div>
                <label for="eta">ETA</label>

                <div class="fill" id="eta"><?php echo $this->generalinfo["eta"] ?></div>
                <label for="ata">ATA</label>

                <div class="fill" id="ata"><?php echo $this->generalinfo["ata"] ?></div>
            </div>
            <div class="cright">
                <label for="ets">ETS</label>

                <div class="fill" id="ets"><?php echo $this->generalinfo["ets"] ?></div>
                <label for="ats">ATS</label>

                <div class="fill" id="ats"><?php echo $this->generalinfo["ats"] ?></div>
                <label for="buoyname">Buoy name</label>

                <div class="fill" id="buoyname"><?php echo $this->generalinfo["buoy_name"] ?></div>
                <label for="departure">Cargo quanity</label>

                <div class="fill" id="departure"><?php echo $this->generalinfo["cargo_quantity"] ?>
                    &nbsp;<?php echo $this->generalinfo["cargo_unit"] ?></div>
                <label for="arrival">Ship on arrival</label>

                <div class="fill" id="arrival">
                    <a href="<?php echo UPLOAD_URL ?><?php echo $this->generalinfo["ship_on_arrival"] ?>" rel="prettyPhoto[pp_gal]">
                        <img width="50px" height="50px" src="<?php echo UPLOAD_URL ?><?php echo $this->generalinfo["ship_on_arrival"] ?>"/>
                    </a>
                </div>

            </div>
            <div style="clear: both;">&nbsp;</div>
        </div>
    <?php endif; ?>
    <?php if (isset($this->dunnage)): ?>
        <div class="c2">
            <h1 style="width:210px;">DUNNAGE MATERIAL</h1>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="row">
                <tr>
                    <th scope="col" class="number">Number</th>
                    <th scope="col" class="type">Type</th>
                    <th scope="col" class="unit">Unit</th>
                    <th scope="col" class="price">Price per unit</th>
                    <th scope="col" class="EDU">Estimated dunnage<br>usage</th>
                    <th scope="col" class="FDU">Final dunnage<br>usage</th>
                    <th scope="col" class="EDC">Estimated dunnage <br>cost (USD)</th>
                    <th scope="col" class="FDC">Final dunnage <br>cost (USD)</th>
                </tr>
                <?php foreach ($this->materials as $material): ?>
                    <?php $i = 1; ?>
                    <tr>
                        <td scope="col" class="number">
                            <?php echo $i; ?>
                        </td>
                        <td scope="col" class="type">
                            <?php echo $material["type"] ?>
                        </td>
                        <td scope="col" class="unit">
                            <?php echo $material["unit"] ?>
                        </td>
                        <td scope="col" class="price">
                            <?php echo $material["price_per_unit"] ?>
                        </td>
                        <td scope="col" class="EDU">
                            <?php echo $material["estimated_dunnage_usage"] ?>
                        </td>
                        <td scope="col" class="FDU">
                            <?php echo $material["final_dunnage_usage"] ?>
                        </td>
                        <td scope="col" class="EDC">
                            <?php echo $material["estimated_dunnage_cost"] ?>
                        </td>
                        <td scope="col" class="FDC">
                            <?php echo $material["final_dunnage_cost"] ?>
                        </td>
                    </tr>
                    <?php $i++; ?>
                <?php endforeach; ?>
                <tr>
                    <td colspan="3" align="center" class="total">Total</td>
                    <td class="totalval">
                        <input type="text" class="entertext" id="totalval" disabled="true"/>
                    </td>
                </tr>
            </table>


            <div style="clear: both;">&nbsp;</div>
        </div>
        <div class="c3">
            <h1 style="width:250px;">DUNNAGE OPERATIONS</h1>

            <div class="cleft">
                <label for="atps">Vessel arrived at p/s</label>

                <div class="fill"
                     id="atps"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->vessel_arrived_at_ps) ?></div>
                <label for="atbuoy">Vessel arrived at buoy</label>

                <div class="fill"
                     id="atbuoy"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->vessel_arrived_at_buoy) ?></div>
            </div>
            <div class="cright">
                <label for="atps">Commenced dunnaging</label>

                <div class="fill"
                     id="atps"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->commenced_dunnaging) ?></div>
                <label for="atbuoy">Completed dunnaging</label>

                <div class="fill"
                     id="atbuoy"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->completed_dunnaging) ?></div>
            </div>
            <div style="clear: both;">&nbsp;</div>
        </div>
        <div class="c4">
            <h1 style="width:320px;">UPDATE DUNNAGE OPERATIONS</h1>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="row" id="tbl_update_dunnage">
                <tbody>
                    <tr>
                        <th scope="col" class="date">Date</th>
                        <?php foreach ($this->update_dunnage_operation_cols as $update_dunnage_operation_col => $name): ?>
                            <th scope="col" class="item-label">
                                <?php echo $name ?>
                            </th>
                        <?php endforeach; ?>
                    </tr>
                    <?php foreach ($this->update as $update): ?>
                        <tr id='tr_<?php echo $update->id ?>'>
                            <td scope="col" class="date">
                                <?php echo date(DATE_FORMAT, $update->date) ?>
                            </td>
                            <?php foreach ($this->update_dunnage_operation_cols as $update_dunnage_operation_col => $name): ?>
                                <td scope="col">
                                    <div class="file-wrapper">
                                        <a href='<?php echo UPLOAD_URL . $update->$update_dunnage_operation_col ?>'  rel="prettyPhoto[pp_gal]">
                                            <img src='<?php echo UPLOAD_URL . $update->$update_dunnage_operation_col ?>' width='80%' height='90%'/>
                                        </a>
                                    </div>
                                </td>
                            <?php endforeach; ?>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
                <tfoot>
                    <tr>
                        <td class="more" colspan="9">
                            <a href="javascript:void(0)" onclick="moreUpdateDunnage('<?php echo $this->dunnage_id ?>')">
                                <img src="<?php echo $this->baseUrl() ?>/public/images/plus.png">
                                View more
                            </a>
                            &nbsp;
                        </td>
                    </tr>
                </tfoot>
            </table>
            <div style="clear: both;">&nbsp;</div>
        </div>
        <div class="c5">
            <h1 style="width:140px;">DOCUMENTS</h1>
            <?php foreach ($this->documents as $doc): ?>
                <div class="<?php echo $doc['file_type'] ?> file-new">
                    <span>
                        <a href='<?php echo UPLOAD_URL . $doc['file'] ?>'target='_blank'>
                            <?php echo $doc['file_name'] ?>
                        </a>
                    </span>
                </div>
            <?php endforeach; ?>
        </div>
        <div style="clear: both;">&nbsp;</div>
    <?php endif; ?>
    <?php if (isset($this->cargo)) : ?>
        <div class="c2">
            <h1 style="width:250px;">CARGO OPERATIONS</h1>

            <div class="cleft">
                <label for="atps">Vessel arrived at p/s</label>

                <div class="fill"
                     id="atps"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->vessel_arrived_at_ps) ?></div>
                <label for="atbuoy">Vessel arrived at buoy</label>

                <div class="fill"
                     id="atbuoy"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->vessel_arrived_at_buoy) ?></div>
                <label for="atps">Commenced dunnaging</label>

                <div class="fill"
                     id="atps"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->commenced_dunnaging) ?></div>
                <label for="atbuoy">Completed dunnaging</label>

                <div class="fill"
                     id="atbuoy"><?php echo date(DATE_FORMAT_H_D_M_Y, $this->operation->completed_dunnaging) ?></div>

                <label for="total_cargo_loaded_upto_date">Total cargo loaded upto date</label>
                <div class="fill"
                     id="total_cargo_loaded_upto_date"><?php echo $this->operation->total_cargo_loaded_upto_date ?>
                </div>

                <label for="ETS">ETS</label>
                <div class="fill"
                     id="ETS"><?php echo $this->operation->ETS ?>
                </div>

                <label for="remarks">Remarks</label>
                <div class="fill"
                     id="remarks"><?php echo $this->operation->remarks ?>
                </div>
            </div>
            <div class="cright">
                <label for="cargo_loaded_on_board">Cargo loaded on board</label>
                <div class="fill"
                     id="cargo_loaded_on_board"><?php echo $this->operation->cargo_loaded_on_board ?>
                </div>

                <label for="gross_weight">Gross weight</label>
                <div class="fill"
                     id="gross_weight"><?php echo $this->operation->gross_weight ?>
                </div>

                <label for="number_of_bags">Number of bags</label>
                <div class="fill"
                     id="number_of_bags"><?php echo $this->operation->number_of_bags ?>
                </div>

                <label for="net_weight">Net weight</label>
                <div class="fill"
                     id="net_weight"><?php echo $this->operation->net_weight ?>
                </div>

                <label for="total_cargo_loaded_last_24h">Total cargo loaded last 24h</label>
                <div class="fill"
                     id="total_cargo_loaded_last_24h"><?php echo $this->operation->total_cargo_loaded_last_24h ?>
                </div>

                <label for="balance_to_load">Balance to load</label>
                <div class="fill"
                     id="balance_to_load"><?php echo $this->operation->balance_to_load ?>
                </div>

                <label for="ATS">ATS</label>
                <div class="fill"
                     id="ATS"><?php echo $this->operation->ATS ?>
                </div>
            </div>
            <div style="clear: both;">&nbsp;</div>
        </div>
        <div style="clear: both;">&nbsp;</div>
        <div class="c5">
            <h1 style="width:140px;">DOCUMENTS</h1>
            <?php foreach ($this->pics as $pic): ?>
                <div class="picture">
                    <a href="<?php echo UPLOAD_URL ?><?php echo $pic ?>" rel="prettyPhoto[pp_gal]">
                        <img width="50px" height="50px" src="<?php echo UPLOAD_URL ?><?php echo $pic ?>"/>
                    </a>
                </div>
            <?php endforeach; ?>
            <?php foreach ($this->videos as $video): ?>
                <div class="video"><a href="#"><?php echo $video ?></a></div>
            <?php endforeach; ?>
        </div>
        <div style="clear: both;">&nbsp;</div>
    <?php endif; ?>
</div>
<script>
    var update_dunnage_offset = 1;
</script>
<script src="<?php echo $this->baseUrl() ?>/public/js/prettyphoto/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo $this->baseUrl() ?>/public/js/detail.js" type="text/javascript" charset="utf-8"></script>